import { Name, URLMESSAGE } from "./interface"

const BASE = 'https://doubaobit.oss-cn-beijing.aliyuncs.com/'
export const ARDUINO_WIN_32 = `${BASE}/arduino/arduino-windows.zip`
export const ARDUINO_WIN_64 = ARDUINO_WIN_32
export const ARDUINO_WIN_DRIVERS_32 = `https://doubaobit.oss-cn-beijing.aliyuncs.com/drivers/wch_ch32.exe`
export const ARDUINO_WIN_DRIVERS_64 = `https://doubaobit.oss-cn-beijing.aliyuncs.com/drivers/wch_ch64.exe`
export const ARDUINO_MAC_DRIVERS_64 = `https://doubaobit.oss-cn-beijing.aliyuncs.com/drivers/CH34x_Install_V1.4.pkg`

export const CPP = 'https://doubaobit.oss-cn-beijing.aliyuncs.com/c%2B%2B/Dev-Cpp_5.11_TDM-GCC_4.9.2_Setup.exe'
export const LEAP_WIN = 'https://doubaobit.oss-cn-beijing.aliyuncs.com/leapmotion/Leap_win.zip'
export const Leap_Linux = 'https://doubaobit.oss-cn-beijing.aliyuncs.com/leapmotion/Leap_Linux.tgz'
export const Leap_Mac = 'https://doubaobit.oss-cn-beijing.aliyuncs.com/leapmotion/Leap_Mac.tgz'




export const Urlmessage: URLMESSAGE = {
    arduino: {
        win32: {
            x64: ARDUINO_WIN_64,
            x32: ARDUINO_WIN_32
        },
        linux: {
            x64: 'https://doubaobit.oss-cn-beijing.aliyuncs.com/arduino/arduino-linux64.tar.xz'
        },
        darwin: {
            x64: 'https://doubaobit.oss-cn-beijing.aliyuncs.com/arduino/arduino-macosx.zip'
        }
    },
    arduinodrivers: {
        win32: {
            x64: ARDUINO_WIN_DRIVERS_64,
            x32: ARDUINO_WIN_DRIVERS_32
        },
        darwin: {
            x64: ARDUINO_MAC_DRIVERS_64
        }
    },
    leap: {
        win32: {
            x64: LEAP_WIN,
            x32: LEAP_WIN
        },
        linux: {
            x64: Leap_Linux,
            x32: Leap_Linux
        },
        darwin: {
            x64: Leap_Mac
        }
    },
    cpp: {
        win32: {
            x64: CPP,
            x32: CPP
        }
    }

}

export default function (name: Name, platform: NodeJS.Platform = 'win32', arch: string = process.arch): string | undefined {
    const d = Urlmessage[name]
    if (d) {
        const f = d[platform]
        if (f) {
            return f[arch]
        }
    }
    return
}